<template>
  <div class="app-container">
    <ht-search-form
      v-show="showSearch"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      rowKey="sysCode"
      :defaultEventKey="entryTable"
    ></ht-search-form>
    <ht-table
      ref="dataTable"
      :showSerialNumber="false"
      :multi-select="true"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
      :defaultEventKey="entryTable"
      :randomRowKey="true"
      @handleSelectionChange="handleSelectionChange"
    ></ht-table>
  </div>
</template>
<script>
import { apiUrlConfig, pack } from "@/api/cnaps/bizMng/hvps_beps_send_byhand.js";
import { listPageMixin } from "@/libs/listPageMixin";
export default {
  name: "HvpsBepsSendByhand",
  mixins: [listPageMixin],
  components: {},
  data() {
    return {
      reqConfig: apiUrlConfig,
      newArr: {
        bepsTable:[],
      },
      //数据字典
      searchFormDictList: ["SYS_CODE", "Cnaps2Dict.BEPS_PKG_TYPE"],
      showSearch: true,
      // 查询参数
      queryParams: {
        id: "",
        workDate1: "",
        workDate2: "",
        msgType: "beps.121.001.01",
        sysCode: "BEPS",
      },
      entryTable:"entryTable",
      formOptions: [],
      selectDataList: [],
      opButtonList: () => {
        return [
          {
            label: "打包",
            type: "primary",
            clickFun: () => {
              this.packFn();
            },
          },
        ];
      },
      tableBindColumns: [
        { label: `交易流水号`, prop: "txnId", width: "200", align: "center" },
        {
          label: `内部批序号`,
          prop: "batchNo",
          width: "160",
          align: "center",
        },
        {
          label: `CPG日期`,
          prop: "cpgdate",
          width: "160",
          align: "center",
          type: "date",
        },
        {
          label: `工作日期`,
          prop: "workdate",
          width: "160",
          align: "center",
          type: "date",
        },
        {
          label: `业务类型`,
          prop: "bizTypeCodeDesc",
          width: "160",
          align: "center",
        },
        {
          label: `业务种类`,
          prop: "bizCtgyCodeDesc",
          width: "160",
          align: "center",
        },
        {
          label: `接收清算行`,
          prop: "payeeStBrno",
          width: "160",
          align: "center",
        },
        {
          label: `发送清算行`,
          prop: "payerStBrno",
          width: "160",
          align: "center",
        },
        {
          label: `付款人账号`,
          prop: "payerActno",
          width: "160",
          align: "center",
        },
        {
          label: `收款人账号`,
          prop: "payeeActno",
          width: "160",
          align: "center",
        },
        {
          label: `业务回执期限`,
          prop: "bizRtrltd",
          width: "160",
          align: "center",
        },
        {
          label: `金额`,
          prop: "amount",
          width: "160",
          align: "center",
          type: "price",
        },
      ],
    };
  },
  mounted() {
    this.formOptions = [
      {
        type: "input",
        prop: "id",
        defaultAttr: {
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "workDate1",
          endTimeName: "workDate2",
        },
        defaultAttr: {
          label: "CPG日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dict",
        dict: "Cnaps2Dict.BEPS_PKG_TYPE",
        prop: "msgType",
        defaultAttr: {
          size: "small",
          label: "报文类型",
          placeholder: "请选择报文类型",
        },
      },
      /*{
        type: "dict",
        dict: "SYS_CODE",
        prop: "sysCode",
        defaultAttr: {
          size: "small",
          label: "系统编号",
          placeholder: "请选择系统编号",
          disabled: true,
        },
      },*/
    ];
  },

  methods: {
    handleSelectionChange(val) {
      this.newArr.bepsTable = val
    },
    packFn() {
      if (this.newArr.bepsTable .length == "0") {
        return;
      }
      this.$set(this.newArr,"id",this.queryParams.id);
      this.$set(this.newArr,"workDate1",this.queryParams.workDate1);
      this.$set(this.newArr,"workDate2",this.queryParams.workDate2);
      this.$set(this.newArr,"msgType",this.queryParams.msgType);
      this.$set(this.newArr,"sysCode",this.queryParams.sysCode);
      pack(this.newArr).then((res) => {
        if (res.code === "S") {
          this.$message({
            type: 'success',
            message: '打包成功'
          });
          this.$refs.dataTable.doQuery();
        }
      });
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
